﻿@{
    ViewBag.Title = "材料牌号选择";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<link href="~/Content/css/common.css" rel="stylesheet" />
<link href="~/Content/css/BlankingcardAdd.css" rel="stylesheet" />
<style type="text/css">
    .tool_c {
        padding: 10px 0;
    }

    .btn-group {
        padding: 1.5em 10px 0 0;
    }

    #layout .condition section {
        float: none !important;
    }

    .frozen_fixed {
        overflow: hidden;
    }

        .frozen_fixed .frozen-bdiv {
            top: 51px !important;
        }

        .frozen_fixed .frozen-div {
            height: 4.2em !important;
        }

        .frozen_fixed .ui-jqgrid-hdiv {
            width: 1900px !important;
            background-color: transparent !important;
        }

        .frozen_fixed .ui-jqgrid-bdiv {
            width: 1900px !important;
            background-color: transparent !important;
        }

        .frozen_fixed .ui-jqgrid-btable {
            background-color: #fff !important;
        }
</style>
<script>
    $(function () {
        Index.init();
    });

    var Index = {
        dataList: null,
        MaterialCode: "@Html.Raw(ViewData["MaterialCode"].ToString())",
        MaterialSizesT: "@Html.Raw(ViewData["MaterialSizesT"].ToString())",
    init: function () {
        with (Index) {
            initControl();

            loadDataList();
        }
    },
    initControl: function () {
        $("#MaterialCode").val(Index.MaterialCode);

        $("#MaterialSizesT").val(Index.MaterialSizesT);

        $("#butnBack").on("click", function () {
            $.goBack();
        });

        $("#btn_search1").on("click", function () {
            var $gridList1 = $("#gridList1");

            var conn1 = {
                "MaterialCode": $("#MaterialCode").val(),
                "MaterialSizesT": $("#MaterialSizesT").val()
            };

            $gridList1.jqGrid('setGridParam', {
                postData: conn1,
            }).trigger('reloadGrid');
        });
    },
    loadDataList: function () {
        var conn1 = {
            "MaterialCode": $("#MaterialCode").val(),
            "MaterialSizesT": $("#MaterialSizesT").val()
        };
        var $gridList1 = $("#gridList1");///BOM/Blankingcard/GetBlankingcards
        $gridList1.dataGridForJson({
            url: "/BOM/Blankingcard/GetBlankingcardMaterialBoards",
            postData: conn1,
            height: $(window).height() - 180,
            colModel: [
            { label: '材料仓库', name: 'FStoreNO', width: 80, align: 'left', sortable: false, frozen: true },
            { label: '定置编号', name: 'FStoreSetNO', width: 80, align: 'center', sortable: false, frozen: true },
            { label: '材料牌号', name: 'MaterialCode', width: 140, align: 'left', sortable: false, frozen: true },
            { label: '材料规格', name: 'MaterialSizes', width: 160, align: 'left', sortable: false, frozen: true },
             { label: '捆包号', name: 'FBatch', width: 140, align: 'left', sortable: false },
            { label: '入库重量', name: 'FQuantity_RK', width: 120, align: 'right', sortable: false},
             { label: '出库重量', name: 'FQuantity_CK', width: 120, align: 'right', sortable: false },
             { label: '库存重量', name: 'FQuantity_RK_FQuantity_CK', width: 120, align: 'right', sortable: false},
            { label: '张数', name: 'FZS_RK_FZS_CK', width: 120, align: 'right', sortable: false },
            { label: '炉号', name: 'FOvenNum', width: 80, align: 'left', sortable: false, frozen: true },
            { label: '出厂日期', name: 'WagonNumber', width: 100, align: 'center', sortable: false, frozen: true },
            { label: '单价', name: 'Fprice', width: 80, align: 'left', sortable: false, frozen: true },
            { label: '金额', name: 'FQuantity_RK_FQuantity_CK_Fprice', width: 80, align: 'right', sortable: false, frozen: true },
            { label: '来料单位', name: 'FHappenCompanyNO', width: 120, align: 'left', sortable: false },
            { label: '来料单位名称', name: 'FHappenCompanyName', width: 160, align: 'left', sortable: false },
            { label: '单据编号', name: 'FDocuNO', width: 120, align: 'left', sortable: false },
            { label: '入库日期', name: 'FCreateDate', width: 100, align: 'center', sortable: false },
            { label: '制造单位', name: 'FProCompanyName', width: 120, align: 'left', sortable: false },
            { label: '标准编号', name: 'StandardNumber', width: 120, align: 'left', sortable: false },
            { label: '特殊要求', name: 'MaterialDemand', width: 160, align: 'left', sortable: false },
            { label: '备注说明', name: 'FDescription', width: 160, align: 'left', sortable: false }
            
            ],
            pager: "#gridPager1",
            sortname: 'FCreateDate  DESC,FCreateTime  DESC',
            viewrecords: true,
            rownumWidth: 50,
            onSelectRow: function (rowId) {
                var cols = "MaterialCode,MaterialSizesT".split(","),cols2="MaterialCode,MaterialSizes".split(","),special="MaterialSizes",i=0;

                rowData = $gridList1.jqGrid('getRowData', rowId);

                cols.forEach(function (item) {
                    var cc = cols2[i++];

                    cc== special && (function(){
                        try {
                            rowData[cc] = rowData[cc].split("x")[0];
                        } catch (e) {
                            rowData[cc] ="";
                        }
                    })();


                    $("#{0}".format(item)).val(rowData[cc]);
                });
            },
            loadComplete: function (data) {
                Index.dataList = data;
            }
        });
        $gridList1.jqGrid('setFrozenColumns');
        $gridList1.jqGrid('setLabel', 0, '序号', 'rowNumberHeaderStyle');
    }
    };



</script>
<div class="layout" id="layout" style="height: 100%; width: 100%;">
    <h1>材料牌号选择</h1>
    <div class="condition">
        <section class="container">
            <div class="row">
                <div class="col-md-2">
                    <label>材料牌号</label>
                    <input id="MaterialCode" name="" placeholder="" type="text" class="form-control required" />
                </div>
                <div class="col-md-2">
                    <label>材料厚度</label>
                    <input id="MaterialSizesT" name="" placeholder="请输入厚度" type="text" class="form-control required" />
                </div>
                <div class="col-md-2">
                    <div class="btn-group">
                        <a id="btn_search1" class="btn btn-primary center-block"><span class="glyphicon glyphicon-search"></span>查询</a>
                    </div>
                </div>
            </div>
        </section>
    </div>
    <div class="table_c">
        <table id="gridList1" class="frozen_fixed"></table>
        <div id="gridPager1"></div>
    </div>
</div>
